package com.liu.community.config;/*
 *@Author:Liu Xing-zhi
 *Description:
 *Date:Crated in 17:57 2021/10/9
 */

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class WebConfig implements WebMvcConfigurer {
    @Autowired
    private  SessionInterceptors sessionInterceptors;
    //添加拦截器
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(sessionInterceptors).addPathPatterns("/**");/*.
        excludePathPatterns("/","/index.html","/index","/gitee/auth","/css/*","/fonts/**","/images/**","/js/**","css/*","fonts/**","images/**","js/**");*///放开不拦截的路径

    }

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/images/upload/**")
                .addResourceLocations("file:D:\\springbootTest\\community\\src\\main\\resources\\static\\images\\upload\\");
    }
}
